package reflect;

import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo4 {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入类名:");
        String str1 = scanner.nextLine();
        System.out.println("请输入方法名:");
        String str2 = scanner.nextLine();
        Class cls = Class.forName(str1);

        Object obj = cls.newInstance();
        Method method = cls.getMethod(str2);
        Object invoke = method.invoke(obj);
        System.out.println(invoke);
    }
}
